using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace HogoWinClient
{
	[Serializable]
	class AppearanceSettings
	{
		static private readonly BinaryFormatter formatter = new BinaryFormatter();
		
		private bool dontShowToolTipForm = false;

		public bool DontShowToolTipForm
		{
			get { return dontShowToolTipForm; }
			set { dontShowToolTipForm = value; }
		}

		#region Singletone
		private AppearanceSettings()
		{}

		static private AppearanceSettings instance = new AppearanceSettings();

		static public AppearanceSettings Instance
		{
			get
			{
				return instance;
			}
		}
		#endregion

		#region Save/Load
		static public void SaveToFile(string fileName)
		{
			Stream stream = File.Open(fileName, FileMode.Create);
			formatter.Serialize(stream, instance);
			stream.Close();
		}

		static public void LoadFromFile(string fileName)
		{
			Stream stream = null;
			try
			{
				stream = File.Open(fileName, FileMode.Open);
				instance = (AppearanceSettings)formatter.Deserialize(stream);
			}
			catch
			{
				instance = new AppearanceSettings();
			}
			finally
			{
				if (stream != null)
					stream.Close();
			}
		}
		#endregion
	}
}
